package inverttree

/**
 * Definition for a binary tree node.
 * type TreeNode struct {
 *     Val int
 *     Left *TreeNode
 *     Right *TreeNode
 * }
 */
 type TreeNode struct {
	     Val int
	     Left *TreeNode
	     Right *TreeNode
	}
 func invertTree(root *TreeNode) *TreeNode {
    // 递归
    if root == nil {
        return root
    }
    root.Left,root.Right = root.Right,root.Left
    invertTree(root.Left)
    invertTree(root.Right)
    return root
}